package com.cainaer.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cainaer.product.domain.CommentReply;
import com.cainaer.product.mapper.CommentReplyMapper;
import com.cainaer.product.service.ICommentReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 评价回复表 服务实现类
 * </p>
 *
 * @author Tina
 * @since 2020-09-11
 */
@Service
public class CommentReplyServiceImpl extends ServiceImpl<CommentReplyMapper, CommentReply> implements ICommentReplyService {

    @Autowired
    private CommentReplyMapper commentReplyMapper;

    /**
     * 新增评论回复数据
     *
     * @param commentReply
     * @return
     */
    @Override
    public Integer insertCommentReply(CommentReply commentReply) {
        return commentReplyMapper.insert(commentReply);
    }

    /**
     * 编辑评论回复
     *
     * @param commentReply
     * @return
     */
    @Override
    public Integer editCommentReply(CommentReply commentReply) {
        return commentReplyMapper.updateById(commentReply);
    }

    /**
     * 根据条件查询回复评论 分页
     *
     * @param commentReply
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public IPage<CommentReply> selectCommentReply(CommentReply commentReply, Integer pageNum, Integer pageSize) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("show_status", 0);
        Page<CommentReply> iPage = new Page<CommentReply>(pageNum, pageSize);
        return commentReplyMapper.selectPage(iPage, queryWrapper);
    }
}
